package com.vint.leetcode;

import com.vint.common.TreeNode;

/*
 * 1. done
 * 2. easy
 * 3. tree, 递归,
 * 求树的深度
 */
//TODO:BFS/DFS
public class Leetcode104 {
    public int maxDepth(TreeNode root) {
        if(null==root)return 0;
        return 1+Math.max(maxDepth(root.left),maxDepth(root.right));
        //return root==null? 0 : Math.max(maxDepth(root.left), maxDepth(root.right))+1;
    }
    public int maxDepthBFS(TreeNode root) {
        return 0;
    }
    public int maxDepthDFS(TreeNode root) {
        return 0;
    }
    public static void main(String[] args) {
        Leetcode104 leetcode104= new Leetcode104();
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.left.left = new TreeNode(5);
        root.right = new TreeNode(4);
        root.right.right= new TreeNode(2);
        TreeNode root1 = new TreeNode(1);
        root1.left = new TreeNode(2);
        System.out.println(leetcode104.maxDepth(root));
        System.out.println(leetcode104.maxDepth(root1));
    }
  }
